package com.bush.mall.product.controller;

import org.springframework.web.bind.annotation.*;
import com.bush.mall.common.entity.Result;;
import com.bush.mall.product.entity.SpuCommentEntity;
import com.bush.mall.product.service.SpuCommentService;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 商品评价
 * @author RUN
 * @date 2022-11-28
 */
@RestController
@RequestMapping("spucomment")
@Api(tags = "商品评价管理" )
public class SpuCommentController {

    @Resource(name= SpuCommentService.BEAN_ID)
    private SpuCommentService spuCommentService;

    /**
     * 分页查询商品评价列表
     * @author RUN
     * @date 2022-11-28
     */
    @ApiOperation(value = "分页查询商品评价列表")
    @GetMapping("queryForPage")
    public Result queryForPage(Integer current,Integer size){
        return spuCommentService.queryForPage(current,size);
    }

    /**
     * 保存商品评价表单
     * @author RUN
     * @date 2022-11-28
     */
    @ApiOperation(value = "保存商品评价表单")
    @PostMapping("saveSpuComment")
    public Result saveSpuComment(@RequestBody SpuCommentEntity spuComment){
        return spuCommentService.saveSpuComment(spuComment);
    }

    /**
     * 修改商品评价表单
     * @author RUN
     * @date 2022-11-28
     */
    @ApiOperation(value = "修改商品评价表单")
    @PutMapping("updateSpuComment")
    public Result updateSpuComment(@RequestBody SpuCommentEntity spuComment){
        return spuCommentService.updateSpuComment(spuComment);
    }

    /**
     * 通过指定id删除商品评价
     * @author RUN
     * @date 2022-11-28
     */
    @ApiOperation(value = "通过指定id删除商品评价")
    @DeleteMapping("deleteSpuComment")
    public Result deleteSpuComment(Long id){
        return spuCommentService.deleteSpuComment(id);
    }

}
